<template>
  <el-container>
    <page-header />
    <el-main class="home-main">
      <div class="search-div">
        <search-book />
      </div>
      <div class="line-spector" />
      <div class="center-container">
        <div class="sidebar">
          <side-bar />
        </div>
        <div class="middle">
          <div class="middle-container">
            <div class="block">
              <!-- <span class="demonstration">默认 Hover 指示器触发</span> -->
              <el-carousel>
                <el-carousel-item v-for="item in staticbook" :key="item.id">
                  <el-image :src="item.url" />
                </el-carousel-item>
              </el-carousel>
            </div>
          </div>
        </div>
        <div class="right">
          <home-right-bar />
        </div>
      </div>
      <book-list />
    </el-main>
    <el-footer class="home-footer" />
    <right-bottom-fixd />
  </el-container>
</template>
<script>

import SearchBook from '@/components/SearchBook'
import SideBar from '@/components/SideBar'
import BookList from '@/components/BookList'
import RightBottomFixd from '@/components/RightBottomFixd'
import PageHeader from '@/components/PageHeader'
import HomeRightBar from '@/components/HomeRightBar'
import * as common from '@/common/common'
export default {
  components: {
    SearchBook,
    SideBar,
    BookList,
    RightBottomFixd,
    PageHeader,
    HomeRightBar
  },
  computed: {
    staticbook() {
      return this.$store.getters.staticbook
    }
  },
  created() {
    this.init()
  },
  methods: {
    init() {
      common.initBookPageFormAndSearchBookForm()
      // 获取一些书籍以便于首页展示
      this.getBookList()
    },
    getBookList() {
      this.$store.dispatch('book/getList')
    }
  }
}
</script>

<style lang="scss" scoped>
a,
a:active {
  text-decoration: none;
  color: #333333;
}
a:hover {
  color: #409eff;
}

.home-main {
  // margin-top: 20px;
  padding: 0 40px;
  .search-div {
    display: flex;
    justify-content: center;
  }
  .line-spector {
    margin-top: 20px;
    border-top: 1px solid lightblue;
  }
  .center-container {
    margin-top: 20px;
    // border-top: 1px solid grey;
    display: flex;
    justify-content: space-around;
    .sidebar {
      flex: 2;
      // background-color: red;
    }
    .middle {
      flex: 6;
      // background-color: rebeccapurple;
      margin: 0 10px;
    }
    .right {
      flex: 2;
      background-color: white;
    }
  }
}

.home-footer {
  margin-top: 50px;
}
</style>
